﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Server.Entity;

namespace Server.Utils
{
    class GlobalConstants
    {
        public static int LocalPort { get; set; }
        public static string Disk { get; set; }
        public static bool IsGetPartNo { get; set; } = false;
        public ClientMsgModel ClientMsgModelInfo { get; set; }
        public static bool ReadIniParam()
        {
            try
            {
                //加载基本参数
                LoadDefaultConfig();
                return true;
            }
            catch (Exception e)
            {
               LogHelper.Error(e);
               return false;
            }
        }

        #region 获取本机IP地址
        //public static string GetIP()   //获取本地IP
        //{
        //    IPHostEntry ipHost = Dns.Resolve(Dns.GetHostName());
        //    IPAddress ipAddr = ipHost.AddressList[0];
        //    return ipAddr.ToString();
        //}
        #endregion

        #region 加载配置文件参数
        public static void LoadDefaultConfig()
        {
            Dictionary<string, string> configDic = ConfigUtils.GetConfig();
            LocalPort = int.Parse(configDic["LocalPort"]);
            Disk = configDic["Disk"];
        }
        #endregion
    }
}
